package com.schoolai.schoolsystem.service.impl;

import com.schoolai.entity.rabbitmq.SmsInfo;
import com.schoolai.schoolsystem.service.ISmsService;
import com.schoolai.util.base.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Copyright(C),2019-2025，XX公司
 * FileName:SmsServiceImpl
 * Author:bobby
 * 创建时间：2025/11/12 10:29
 * Description:ISmsService实现
 * History:
 * <auth>        <time>       <version>       <desc>
 * 作者          修改时间       版本号         描述
 */
@Service
@Slf4j
public class SmsServiceImpl implements ISmsService {
    @Autowired
    private AmqpTemplate rabbitTemplate;
    @Override
    public Result sendSms(String phone, String content) {
        SmsInfo smsInfo = new SmsInfo();
        smsInfo.setPhone(phone);
        smsInfo.setContent(content);
        smsInfo.setSendTime(new Date());
        log.info("手机号码：{},信息内容：{},发送时间：{}", smsInfo.getPhone(), smsInfo.getContent(), smsInfo.getSendTime());
        rabbitTemplate.convertAndSend("SMSQueue",smsInfo);
        return Result.ok();
    }
}
